From 741bcc86e29e8d46285d46a63225186c74d34bc3 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 12 Apr 2010 18:28:33 +0100 Subject: [PATCH] xentrace: fix lost records resume Reorder the SCHED_SWITCH trace before the runstate change trace to fix a problem with the lost records "resume" code. Namely: The "lost records" trace includes the currently running process. But during SCHED_SWITCH, it reads the wrong value, confusing xenalyze. Making sure there are no trace records between runstate change trace and the actual context switch fixes it. Signed-off-by: George Dunlap --- xen/common/schedule.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index fdb9e8d0d2..70289041d2 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -877,6 +877,11 @@ static void schedule(void) next_slice.time); ASSERT(prev->runstate.state == RUNSTATE_running); + + TRACE_4D(TRC_SCHED_SWITCH, + prev->domain->domain_id, prev->vcpu_id, + next->domain->domain_id, next->vcpu_id); + vcpu_runstate_change( prev, (test_bit(_VPF_blocked, &prev->pause_flags) ? RUNSTATE_blocked : @@ -887,6 +892,11 @@ static void schedule(void) ASSERT(next->runstate.state != RUNSTATE_running); vcpu_runstate_change(next, RUNSTATE_running, now); + /* + * NB. Don't add any trace records from here until the actual context + * switch, else lost_records resume will not work properly. + */ + ASSERT(!next->is_running); next->is_running = 1; @@ -900,10 +910,6 @@ static void schedule(void) update_vcpu_system_time(next); vcpu_periodic_timer_work(next); - TRACE_4D(TRC_SCHED_SWITCH, - prev->domain->domain_id, prev->vcpu_id, - next->domain->domain_id, next->vcpu_id); - context_switch(prev, next); } -- 2.30.2